<?php $id="form_".uniqid();?>
<table id="<?php echo $id;?>"></table>
<script>
$("#<?php echo $id;?>").DataSource({url:'member/getchild',
	fields:[[
		{field:'id',      title:'ID', align:'center',width:60,sortable:true},
		{field:'online',title:'状态 ', align:'center', width:70, sortable:false,formatter:function (v,r) {
            if (v== 1) return '在线';
            if (v== 2) return '离线';
        }},
        {field:'username', title:'帐号',        width:120,},
		{field:'name',     title:'名称 ',       width:100,},	
		{field:'logintime',title:'最后登录时间', width:160,},	
		{field:'loginip',  title:'最后登录IP',   width:160,},	
		{field:'addtime',  title:'新增日期',     width:150,  sortable:true,formatter:function(v){return date('Y-m-d H:i:s',v)}},
		{field:'t7',       title:'登录错误次数', width:80,  sortable:true},
		{field:'status',   title:'当前状态',     width:100,  sortable:true,formatter:function (v,r) {
            if (v== 1) return '正常';
            if (v== 2) return '停用';
            if (v== 3) return '锁定';
        }},
		{field:'aa',       title:'功能',         width:260,sortable:false,formatter:function(v,r){
			return '<a herf="#" class="btn btn-danger btn-xs" onclick=Core.dialog("子账号权限管理","member/get_power?id='+r.id+'",function(){},true,false);>权限</a>&nbsp;&nbsp;'+
			'<a herf="#" class="btn btn-'+(r.status==1?'danger':'success')+' btn-xs" onclick=updateStatus('+r.id+','+r.status+')>'+(r.status==2?'开启':'暂停')+'</a>&nbsp;&nbsp;'+
			'<a herf="#" class="btn btn-danger btn-xs" onclick=Core.confirm("<?php echo $id;?>",1,"asd","确定删除该会员使用?")>删除</a>&nbsp;';
		}}
    ]], tools:[
	{instant:false},
	<?php if(in_array('ADD',$auth)){?>
	{text:"新增",iconCls:"icon-add",handler:function(){
		$('#<?php echo $id?>').DataSource('add',{title:'新增子账号',get:'member/editchild',full:false});
	}},
	<?php }?>
    <?php if(in_array('EDIT',$auth)){?>
    {text:"编辑",iconCls:"icon-edit",handler:function(){
        $('#<?php echo $id?>').DataSource('edit',{title:'查看会员',get:'member/editchild',full:false});
    }},
    <?php }?>
	<?php if(in_array('DELETE',$auth)){ ?>
	{text:"删除",iconCls:"icon-remove",handler:function(){
		$('#<?php echo $id?>').DataSource('remove',{get:'member/delete_user'});
	}},
	<?php }?>
	'|',
		
		{type:'textbox', text:'帐号', width:100,name:'zaddtime'},
		{type:'textbox', text:'名称', width:100,name:'zaddtime'},
		{text:"搜索", iconCls:"icon-search", handler:function(){
			$('#<?php echo $id?>').DataSource('search');
		}},
	'-'
	],
	footer:true,
	success:function(){

	}
});
function updateStatus(id,status){
	$.messager.confirm('温馨提示', '确定'+(status==1?'停用':'开启')+'该帐号使用吗', function(r){
		if (r){
			$.post(WEB+'member/update_status',{id:id,status:status},function(c){
				$('#<?php echo $id?>').datagrid('reload');
			});
		}
	});
}
</script>

